<template>
	<div class="lazy">lazy page</div>
</template>

<script setup>
	const BASE_URL = 'http://codercba.com:9060/juanpi/api'

	/* // useFetch 会默认阻塞页面的导航, 必须要useFetch结束后才能跳转到导航
	const { data } = await useFetch(BASE_URL + '/homeInfo', {
		lazy: true,
	})

	console.log(data.value?.data)

	onMounted(() => {
		console.log('onMounted')
	})

	// 确保页面一定能获取到数据
	watch(data, (newData) => {
		console.log('data =>', data)
	}) */

	// 上述方式的简写
	const { data } = await useLazyFetch(BASE_URL + '/homeInfo', {
		lazy: true,
	})

	console.log(data.value?.data)

	onMounted(() => {
		console.log('onMounted')
	})
</script>

<style lang="scss" scoped></style>
